<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="用户" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doNew(){
		var url="/system/UserNew.ihtm";
		ShowIframeNoScroll("用户",url,400,460,"doNewCallBack()",600,530);
	}
	function doNewCallBack(){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			setTimeout("doPermission("+arr[0]+",'"+arr[1]+"','MODEL_PRIVILEGE')",1000*1);
		}else{
			refreshWin();
		}
	}
	function doEdit(id){
		var url="/system/UserEdit.ihtm?id="+id;
		ShowIframeNoScroll("用户",url,400,460,"refreshWin()",600,530);
	}
	function refreshWin(){
		window.location.reload(true);
	}
	function doDelete(id){
		ShowConfirm('确认框','确定删除吗？',340,80,"doDelAct("+id+")");
	}
	function doDelAct(id){
		if(popRetVal!=null){
			var fromUrl=encodeURIComponent("/system/UserList.ihtm");
			window.location="/system/UserDelete.ihtm?id="+id+"&from_url="+fromUrl;
		}
	}
	function doPermission(userId,stafName,privilegeType){
		var url="/system/UserPriSetTypeSelect.ihtm";
		ShowIframeNoScroll(stafName,url,420,280,"doPermissionCallBack("+userId+",'"+stafName+"','"+privilegeType+"')",600,530);
	}
	function doPermissionCallBack(userId,stafName,privilegeType){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			var templateId="";
			if(arr[0]=="COPY"){
				templateId=arr[1];
			}
			setTimeout("doPermissionCallBackExt("+userId+",'"+stafName+"','"+privilegeType+"','"+templateId+"')",500*1);
		}else{
			refreshWin();
		}
	}
	function doPermissionCallBackExt(userId,stafName,privilegeType,templateId){
		var url="/system/UserPrivilegeList.ihtm?user_id="+userId+"&privilege_type="+privilegeType+"&template_id="+templateId;
		ShowIframe(stafName,url,900,500,"refreshWin()",600,530);
	}
	function doCancel(){
		window.close();
	}
	function doPause(id,flag){
		var fromUrl=encodeURIComponent("/system/UserList.ihtm");
		window.location="/system/UserPause.ihtm?id="+id+"&flag="+flag+"&from_url="+fromUrl;
	}
</script>
</head>
<body oncontextmenu="return false" class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:560px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>用户管理</h2>
      <p>设置员工的登录账号以及使用权限</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
	    <div class="add_content"> 	
	    	 <div align="right"><input type="button" class="buttom search-add" value="  新 增 " onClick="doNew();"></div>
	     </div>
	     <%@include file="../inc/AlertMsg.jsp"%>
	     <div class="table-list">
	        <table width="100%">
	          <tr>
							<th width="15%">登录账号</th>
							<th width="18%">职员姓名</th>
							<th width="15%">设置有效期</th>
							<th width="18%">有效期至</th>
							<th width="10%">状态</th>
							<th width="24%">操作</th>
						</tr>
						<c:forEach var="item" items="${userList}">
						<tr>
							<td>${item[1]}</td>
							<td>${item[2]}</td>
							<td>
								<c:if test="${item[5]=='Y'}">
									<c:if test="${item[3]=='Y'}"><font color="#ff0000">是</font></c:if>
									<c:if test="${item[3]=='N'}">否</c:if>
								</c:if>
							</td>
							<td>
								<c:if test="${item[5]=='Y' && item[3]=='Y' && item[4]!=null}">
									<fmt:formatDate value="${item[4]}" pattern="yyyy-MM-dd"/>
								</c:if>
							</td>
							<td>
								<c:if test="${item[5]=='N'}"><font color="#ff0000">停用</font></c:if>
								<c:if test="${item[5]=='Y'}">
									<c:if test="${item[3]=='Y' && item[6]=='Y'}"><font color="#ff0000">过期</font></c:if>
									<c:if test="${item[3]!='Y' || item[6]!='Y'}">正常</c:if>
								</c:if>
							</td>
							<td>
								<a href="javascript:doEdit('${item[0]}');">编辑</a>
								<c:if test="${item[5]=='N'}"><a href="javascript:doPause('${item[0]}','Y');">启用</a></c:if>
								<c:if test="${item[5]=='Y'}"><a href="javascript:doPause('${item[0]}','N');">停用</a></c:if>
								<a href="javascript:doPermission('${item[0]}','<c:out value="${item[2]}" />','MODEL_PRIVILEGE');">授权</a>
								<a href="javascript:doDelete('${item[0]}');">删除</a>
							</td>
						</tr>
						</c:forEach>
					</table>
		     </div>  
	   </div>  
  </div>
<div class="blank12"></blank>
</div>
</body>
</html>
